package Day217;

import java.util.Arrays;

public class ArrayDemo {
    public static void main(String[] args) {
        /*
        int[] a={10,20,30,40,50};
        int[] b=new int[6];
        System.arraycopy(a,1,b,1,3);
        for(int i=0;i<b.length;i++){
            System.out.println(b[i]);
        }

        int[] a={10,20,30,40,50};
        int[] b=new int[5];
        System.arraycopy(a,0,b,0,5);
        for(int i=0;i<b.length;i++){
            System.out.println(b[i]);
        }

        int[] a={10,20,30,40,50};
        a= Arrays.copyOf(a,a.length+1);
        for(int i=0;i<a.length;i++){
            System.out.println(a[i]);
        }

        int[] arr=new int[10];
        for(int i=0;i<arr.length;i++){
            arr[i]=(int)(Math.random()*100);
            System.out.println(arr[i]);
        }
        int max=arr[0];
        for(int i=1;i<arr.length;i++){
            if(arr[i]>max){
                max=arr[i];
            }
        }
        System.out.println("max="+max);
        arr=Arrays.copyOf(arr,arr.length+1);
        System.out.println("扩容后:");
        arr[arr.length-1]=max;
        for(int i=0;i<arr.length;i++){
            System.out.println(arr[i]);
        }

        int[] arr=new int[10];
        for(int i=0;i<arr.length;i++){
            arr[i]=(int)(Math.random()*100);
            System.out.println(arr[i]);
        }
        Arrays.sort(arr);
        System.out.println("排序后:");
        for(int i=0;i<arr.length;i++){
            System.out.println(arr[i]);
        }
        int max=arr[0];
        for(int i=1;i<arr.length;i++){
            if(arr[i]>arr[0]){
                max=arr[i];
            }
        }
        System.out.println("max="+max);


        arr=Arrays.copyOf(arr,arr.length+1);
        arr[arr.length-1]=max;
        for(int i=0;i<arr.length;i++){
            System.out.println(arr[i]);
        }

        int[] a={10,20,30,40,50};
        int[] b=new int[7];
        System.arraycopy(a,0,b,1,5);
        for(int i=0;i<b.length;i++){
            System.out.print(b[i]+"\t");
        }

         */
        int[] a={10,20,30,40,50};
        int[] b=Arrays.copyOf(a,6);
        for(int i=0;i<b.length;i++){
            System.out.print(b[i]+"\t");
        }



























    }
}
